package com.tamecode.chapter06.sec45;

import lombok.Data;

import javax.sql.DataSource;

/**
 * 测试 Bean 数据引用
 * @Author: Qiongchao
 * @Version: 1.0.0
 * @Date: 2023/9/26
 */
@Data
public class SysConfig {

    private int sessionTimeout;
    private int maxTabPageNum;
    private DataSource dataSource;

    //①模拟从数据库中获取配置值并设置相应的属性
    public void initFromDB(){
        /*try {
            Connection connection = dataSource.getConnection();
            Statement statement = connection.createStatement();
            boolean execute = statement.execute("select * from t_user limit 1");
            if (execute) {
                ResultSet resultSet = statement.getResultSet();
                System.out.println(resultSet);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }*/
        //模拟从数据库获取配置值
        this.sessionTimeout = 30;
        this.maxTabPageNum = 10;
    }

}
